package com.xsh.opensltest.plugin;

// 测试用 will be removed in future
import android.util.Log;
import android.view.View;
import android.widget.SeekBar;
import android.widget.Toast;

import com.xsh.opensltest.App;
import com.xsh.opensltest.DawActivity;
import com.xsh.opensltest.SlEngine;

public class PluginEventHandlerTest {
    private final DawActivity context;
    private static String tag = "PluginEventHandlerText";

    public PluginEventHandlerTest(DawActivity context) {
        this.context = context;
    }

    // 处理点击事件
    public void handleClick(View view, String methodName)
    {
        Log.d(tag,"clicked: " + methodName);
        switch (methodName) {
            case "play":
                //SlEngine.play();
                Toast.makeText(App.appContext,"called from" + this.toString(),Toast.LENGTH_LONG).show();
                break;
            case "stop":
                //SlEngine.stop();
                break;
            default:
                Toast.makeText(context, "Unknown method: " + methodName, Toast.LENGTH_SHORT).show();
        }
    }

    // 处理SeekBar变化事件
    public void handleSeekBarChange(SeekBar seekBar, int progress, String methodName)
    {
        if ("setAmplitude".equals(methodName)) {
            SlEngine.sendEvent("setAmplitude", progress / 100.0);
        }
    }
}